//
//  AIGirlLevelAnimateView.swift
//  AIGirl
//
//  Created by Rae on 2024/1/23.
//

import UIKit
import SwiftEntryKit

class AIGirlLevelAnimateView: UIView, AnimationProtocol, AnimationDelegate, AIGirlLottieAnimationProtocol {

    func animationContainerViewSize() -> CGSize {
        CGSize(width: .screenWidth, height: .screenHeight)
    }
    
    func animationContainerViewStyle() -> AnimationViewStyle {
        .center
    }
    
    var type: String = "" {
        didSet {
            animateView.type = type
        }
    }
    
    var content: String = "" {
        didSet {
            contentLabel.text = content
        }
    }
    
    private lazy var animateView = levelAnimateView()
    private lazy var contentLabel   = c_make_ex(UILabel.self)
        .color(.white.alpha(0.84)).font(16.font_medium).alignment(.center).line(0)
        .text(" Sweetheart, a smooch for you! Are you here? I'd love to hear about any happy little things in your life! 😘❤️").end()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = "#19151F".toColor.alpha(0.6)
        
        subviews{
            animateView
            contentLabel
        }
        let w = CGFloat.screenWidth - 40.0
        animateView.width(w).height(w).centerVertically(offset: -60.0).centerHorizontally()
        contentLabel.leading(30.Scale).trailing(30.Scale)
        contentLabel.Top == animateView.Bottom - 40
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        animation.animation(dismiss: self)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
